package main

import (
	"os"

	"ckeadm/cmd"
	hiddencmd "ckeadm/cmd/hidden"
	logscmd "ckeadm/cmd/logs"
	"ckeadm/version"
	"github.com/sirupsen/logrus"
	"github.com/urfave/cli"
)

func main() {
	var commands = []cli.Command{
		cmd.CreateCommand(),    // ckeadm create
		cmd.StopCommand(),      // ckeadm stop
		cmd.TransFormCommand(), // ckeadm transform
		cmd.DeleteCommand(),    // ckeadm delete
		cmd.UpgradeV4Command(), // ckeadm upgrade to v4
		cmd.ComponentCommand(), // ckeadm component
		cmd.DiffCommand(),      // ckeadm diff

		// logs and status
		logscmd.StatusCommand(),  // ckeadm status
		logscmd.WaitCommand(),    // ckeadm wait
		hiddencmd.WatchCommand(), // ckeadm watch

		// show version
		version.GetVersionCommand(),
	}

	if err := AppCkeadm(commands...).Run(os.Args); err != nil {
		logrus.Fatal(err)
	}
}

func AppCkeadm(commands ...cli.Command) *cli.App {
	var app = cli.NewApp()

	app.Name = "ckeadm"
	app.Version = version.VERSION
	app.Usage = "ckeadm kubernetes engine, use to deploy kubernetes cluster"
	app.Author = "inspur"

	app.Commands = append(app.Commands, commands...)
	return app
}
